{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "34092fc9-5cb3-4dc8-a11c-7c0b53281117",
   "metadata": {},
   "source": [
    "# Hexbin Plot of Earthquake Locations\n",
    "\n",
    "A hexbin plot showing the spatial distribution of earthquakes by longitude and latitude. Hexagonal bins count how many events occurred in each region."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "39d6dce3-22ab-4dfe-b3c1-ef93898008f6",
   "metadata": {},
   "outputs": [],
   "source": [
    "import hvplot.pandas  # noqa\n",
    "\n",
    "df = hvplot.sampledata.earthquakes(\"pandas\")\n",
    "\n",
    "df.hvplot.hexbin(\n",
    "    x='lon',\n",
    "    y='lat',\n",
    "    gridsize=30,\n",
    "    data_aspect=1,\n",
    "    cmap='viridis_r',\n",
    "    title='Earthquake Density by Location (Bokeh)',\n",
    "    xlabel='Longitude',\n",
    "    ylabel='Latitude',\n",
    ")"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e1cba918-7227-4121-95e6-d38e354cee14",
   "metadata": {},
   "outputs": [],
   "source": [
    "import hvplot.pandas  # noqa\n",
    "hvplot.extension('matplotlib')\n",
    "\n",
    "df = hvplot.sampledata.earthquakes(\"pandas\")\n",
    "\n",
    "df.hvplot.hexbin(\n",
    "    x='lon',\n",
    "    y='lat',\n",
    "    gridsize=30,\n",
    "    data_aspect=1,\n",
    "    width=600,\n",
    "    cmap='viridis_r',\n",
    "    title='Earthquake Density by Location (Matplotlib)',\n",
    "    xlabel='Longitude',\n",
    "    ylabel='Latitude',\n",
    ")"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "aa74b702-eb9d-4592-ad71-889ca55be757",
   "metadata": {},
   "source": [
    ":::{seealso}\n",
    "- [Hexbin reference documentation](../../ref/api/manual/hvplot.hvPlot.hexbin.ipynb).\n",
    ":::"
   ]
  }
 ],
 "metadata": {
  "language_info": {
   "name": "python",
   "pygments_lexer": "ipython3"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
